package com.znsd.dining.room.response;

import org.apache.commons.httpclient.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ResultData
 * @Description: 返回结果集
 * @Author timi
 * @Date 2020/1/2
 * @Time 16:15
 * @Version V1.0
 **/
public class ResultData extends HashMap<String,Object> {
    
    public ResultData(){
        put("code",200);
        put("msg","success");
    }
    
    public static ResultData error(){
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }
    
    public static  ResultData error(String msg){
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }
    
    public static ResultData error(int code, String msg){
        ResultData resultData = new ResultData();
        resultData.put("code", code);
        resultData.put("msg", msg);
        return  resultData;
    }
    
    public static ResultData ok(String msg){
        ResultData resultData = new ResultData();
        resultData.put("msg", msg);
        return resultData;
    }
    
    public static ResultData ok(Map<String, Object> map){
        ResultData resultData = new ResultData();
        resultData.putAll(map);
        return resultData;
    }
    
    public static ResultData ok(){
        return  new ResultData();
    }
    
    @Override
    public  ResultData put(String key, Object value){
        super.put(key, value);
        return this;
    }
}
